<?php
declare(strict_types=1);
/**
 * Created by PhpStorm
 * User: Administrator
 * Date: 2023/8/24
 * Time: 14:11:51
 */

namespace Service\CommodityService;

use App\Model\BbcModel\GoodsTags;
use Service\Code\Normal;

/**
 * 供应商标签
 */
class SupplierGoodsTag extends \Service\BaseService
{
    public function list($param) : array{

        $where = [
            ['cid','=',$param['cid']],
            ['df','=',0],
            ['type','=',0],
        ];
        if(isset($param['name']) && $param['name'] != ''){
            $where[] = ['name','like',"%{$param['name']}%"];
        }
        $page = $param['page'] ?? 1;
        $limit = $param['limit'] ?? 10;
        $data_list = GoodsTags::instance()
            ->where($where)
            ->orderByRaw('sort desc,id desc')
            ->paginate($limit, ['id','name','show_name','desc'], 'page', $page);

        $list = $data_list->items();
        $total = $data_list->total();
        return Normal::returnCode(Normal::SUC,'请求成功',['list'=>$list,'total'=>$total]);

    }
}